package com.oneinlet.controller;

import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;

@Controller
@RequestMapping("/web")
public class TemplateController {

    @RequestMapping("/a")
    public ModelAndView index1() {
        ModelAndView mv = new ModelAndView();
        mv.addObject("introduce", "欢迎使用Thymeleaf,来自一个开源项目框架，https://gitee.com/bookteam/General-SpringBoot-Demo!");
        mv.setViewName("/index");
        return mv;
    }

    @RequestMapping("/")
    public String index(Model map) {
        // 加入一个属性，用来在模板中读取
        map.addAttribute("introduce", "欢迎使用Thymeleaf,来自一个开源项目框架,https://gitee.com/bookteam/General-SpringBoot-Demo!");
        // return模板文件的名称，对应src/main/resources/templates/index.html
        return "index";
    }
}
